let users = {
    Alan: {
        age: 27,
        online: false
    },
    Jeff: {
        age: 32,
        online: true
    },
    Sarah: {
        age: 48,
        online: false
    },
    Ryan: {
        age: 19,
        online: true
    }
};

function countObj(obj){
    var objAttrList=Object.keys(obj)
    var num=0;
    objAttrList.forEach(attr=>{
        if(obj[attr].online){
            num+=1;
        }
    })
    console.log(num);
}

countObj(users)